' ------------------------------------------------------------------------------------
' This is a simple HTML generator written in VBScript
'
' It uses the current album or a user specified album to build a Framed HTML file.
' This file processes all the selected pictures.
' This is version 4 which includes the FORM tags so that the forms are created in Netscape
' ------------------------------------------------------------------------------------
Option Explicit
' To run this script outside of MyAlbum, un-comment the 2 following lines:
'dim app
'set app = CreateObject("MyAlbum.Application")
app.ClearTrace
Dim alb, pic
if GetAlbum( alb ) then
MsgBox( "This script will add the selected pictures to a Framed HTML page. If you want alternate text to show when mouse is over the thumbnail, First fill out the Information field for each pic in the album by right mouse clicking on the pic and selecting Information. Please select OK to continue")
'app.Trace "Output file = " & outputFileName
Dim outputFileName
outputFileName = InputBox( "Please enter the name of the INDEX HTML file to create", "Simple HTML generator", "index.html")
app.Trace "Output file = " & outputFileName
Dim backgroundImg
backgroundImg = InputBox( "Please enter the file name for the background image", " ")
app.Trace "Background Image = " & backgroundImg
Dim backgroundcolor
backgroundcolor = InputBox( "Please enter the color for the background, choices are: black, white, green, blue, red, purple, violet, yellow, and any other basic color", "Simple HTML generator", "white")
app.Trace "Background Color = " & backgroundcolor
Dim fontcolor
fontcolor = InputBox( "Please enter the color for the font, choices are: black, white, green, blue, red, purple, violet, yellow, and any other basic color", "Simple HTML generator", "black")
app.Trace "Font Color = " & fontcolor
Dim titlename
titlename = InputBox( "Use this Title or enter a new Title for the web page to create", "Simple HTML generator", alb.sAlbumTitle )
app.Trace "Web Page Title = " & titlename
Dim maintext
maintext = InputBox( "Please enter a text description to display in the main window of the web page to create", "Simple HTML generator", alb.sAlbumComment )
app.Trace "Web Page Description = " & maintext
Dim backlink
backlink = InputBox( "Do you want a back button to a higher level web page?", "Simple HTML generator", "yes" )
app.Trace "Back Button = " & backlink
if backlink = "yes" then
Dim backname
backname = InputBox( "Enter the name of the web file that resides one directory up to link to.", "Simple HTML generator", "index.html" )
app.Trace "File to link to = " & backname
end if
Dim bgmusic
bgmusic = InputBox( "Do you want MIDI music for this web page?", "Simple HTML generator", "no" )
app.Trace "MIDI Music = " & bgmusic
if bgmusic = "yes" then
Dim midiname
midiname = InputBox( "Enter the name of the midi file, you will need to put it in the same directory.", "Simple HTML generator", " .mid" )
app.Trace "MIDI File Name= " & midiname
end if
Const ForReading = 1, ForWriting = 2
Dim fso, f, m, picPath
Set fso = CreateObject("Scripting.FileSystemObject")
' This part works and picPath is equal to the absolute path and pic file name.
' First get the path relative to the album
Set pic = alb.GetVisiblePicture(0)
picPath = alb.ExpandMacro( pic, "%RP" )
app.Trace "The path for the first picture is " & picPath
dim k, pathstring
k = instrrev(picPath,"\") ' Search for the last back-slash
pathstring = left(picPath, k)
app.Trace "The pathstring is " & pathstring
Set f = fso.OpenTextFile( pathstring & outputFileName, ForWriting, True)
f.WriteLine ""
f.WriteLine "
"
f.WriteLine " "
f.WriteLine " "
f.WriteLine " " & titlename & ""
f.WriteLine ""
f.WriteLine ""
f.WriteLine ""
app.Trace "Page " & outputfilename & " created "
f.Close
'
' This section creates the top.html file
'
' Set topFileName = top.html
Set f = fso.OpenTextFile( pathstring & "top.html", ForWriting, True)
f.WriteLine ""
f.WriteLine ""
f.WriteLine ""
f.WriteLine "top"
f.WriteLine ""
f.WriteLine ""
if backlink = "yes" then
f.WriteLine ""
f.WriteLine " BACK | "
f.WriteLine " " & titlename & " | "
f.WriteLine "
"
else
f.WriteLine " " & titlename & "
"
end if
f.WriteLine ""
f.WriteLine ""
app.Trace "Page top.html created "
f.Close
'
' This section creates the main.html file
'
Set f = fso.OpenTextFile( pathstring & "main.html", ForWriting, True)
f.WriteLine ""
f.WriteLine ""
f.WriteLine "main"
f.WriteLine ""
f.WriteLine ""
f.WriteLine "
"
f.WriteLine ""
f.WriteLine ""
f.WriteLine ""
f.WriteLine "" & maintext & " "
f.WriteLine " |
"
f.WriteLine ""
f.WriteLine ""
app.Trace "Page main.html created "
f.Close
'
'
' This section creates the menu.html file
'
app.Trace "Page menu.html being created "
Set f = fso.OpenTextFile( pathstring & "menu.html", ForWriting, True)
f.WriteLine ""
f.WriteLine ""
f.WriteLine " " & titlename & ""
f.WriteLine ""
f.WriteLine ""
f.WriteLine ""
if bgmusic = "yes" then
f.WriteLine ""
end if
f.WriteLine "
"
f.WriteLine ""
'
'
' The following lines go to the creation of the MENU files
'
'
' Process each selected picture
Dim nbPic, i, flsh, flshval
nbPic = alb.nbVisiblePicture
app.Trace "Pictures to process in this album: " & nbPic
f.WriteLine "
"
if backlink = "yes" then
f.WriteLine "
"
f.WriteLine " BACK | "
f.WriteLine "
"
end if
f.WriteLine "
Build with MyAlbum script"
f.WriteLine "
Created by:"
f.WriteLine "
mpilihp@yahoo.com"
f.WriteLine "
With help by:"
f.WriteLine "
pierre.meindre@libertysurf.fr"
f.WriteLine "
With code from:"
f.WriteLine "
r.p.feria@ieee.org"
f.WriteLine "
Steve@sdean.demon.co.uk"
f.WriteLine ""
f.WriteLine ""
f.Close
app.Trace nbPic & " picture processed."
app.Trace "HTML file generation complete !"
app.Trace "This script creates a web page that uses thumbnail pictures in the menu."
app.Trace "Create these from My Album Tools -> Export Album menu option."
app.Trace "Select -Save Thumbnails- then set Output Directory to where this albums images are located, and prest Start!"
MsgBox( "Please read the last three lines in trace for instructions on completing this WEB page." & vbcrlf & "Please select OK to continue")
' Launch browser
app.Run pathstring & outputFileName, True, 1
else
app.Trace "No album to process, exiting !"
end if
' ********************************************************************************
' *
' * GetAlbum : get the current album or prompt the user to select one
' *
Function GetAlbum( byref alb )
GetAlbum = True
' First try to use the current album
set alb = app.GetCurrentAlbum
if alb is nothing then ' No album is open
dim albFile
albFile = InputBox( "Please enter the name of the album to process", "Simple HTML generator", "")
set alb = app.LoadAlbum( albFile )
if alb is Nothing then
GetAlbum = False
end if
end if
End Function